看题目是sql注入相关,正好开始学一下。
初始站点有个post
框框,输个1
进去抓包,了解到参数是$id
,转到intruder
模块随便拿了个payload对$id
爆破一下,发现几种回显:
Nu1L
bool(false)
SQL Injection Checked.
Error Occured When Fetch Result.
V&N
通过SQL Injection Checked.
发现and
,or
,information_schema
,union select
被过滤了
不报数据库语法错误信息,反而有很奇怪的Nu1L
和V&N
,像布尔盲注。
盲注原理:屏蔽了报错信息,无法通过报错信息来进行注入判断。
布尔盲注:无论输入什么,只显示真假。
但是我只知道布尔盲注这个名字(微笑)。经过一番学习,明白了一点儿。
手动测一下库长
2||length(database())>10
回显Nu1L
2||length(database())>21
回显V&N
2||length(database())>=21
回显Nu1L
写脚本之前还要先学一下绕过information_schema
,翻翻别的师傅的博客,了解到:
infromation_schema
库的作用就是获取table_schema
,table_name
,column_name
数据库内的信息。
由于
performance_schema
过于繁复,所以mysql
在5.7
版本中新增了sys schemma
,基础数据来自于performance_chema
和information_schema
两个库,本身数据库不存储数据。
因此可以用:
1 | select group_concat(table_name) from sys.schema_table_statistics_with_buffer where table_schema=database() |
替换
1 | select table_name from information_schema.tables where table_schema=database() |
其中:
1 | group_concat ( [distinct(去冗余)] 要连接的字段 [order by 排序字段 asc/desc ] [separator '分隔符'] )默认以,分隔 |
看别人wp有用异或注入的,简单了解一下MYSQL
里的异或注入:^
连接的两个表达式,如果结果相同判断为假,结果不同判断为真。
还有直接用||
的。
理解了一下别人写的脚本:
1 | import requests |
爆出库名:users233333333333333
f1ag_1s_h3r3_hhhhh
然后是无列名注入:
无列名注入
用
1 | (select 1,{})>(select * from f1ag_1s_h3r3_hhhhh) |
替换
1 | select b from (select 1,2,3 as b union select * from admin)a; |
研究一下别人的脚本:
总思路就是通过字符串比较,要注意-
符号。
1 | ''' |
再转一下小写得到flag,太艰难了吧。。
tips
1.information_schema
被过滤时,考虑无列名注入。
2.了解一下sys.schema_table_statistics_with_buffer
3.还有今天才学会markdown
可以给代码上语言格式。。我好迟钝。
参考
https://blog.csdn.net/weixin_43940853/article/details/106164162
https://www.anquanke.com/post/id/193512
Author: suyumen
Link: https://suyumen.github.io/2021/05/08/2021-05-08-[GYCTF2020]Ezsqli/
Copyright: All articles in this blog are licensed under CC BY-NC-SA 3.0 unless stating additionally.